<?php
namespace app\api\controller;
use app\model\Items;
use app\model\OpAccount;
use think\Model;
use app\model\ItemConsume;
class Paymsg{
    
    public function index(){
        
        
    }
    
    // 获取所有再跑账户,最近7次的平均消耗
    function get_acc_info(){
        set_time_limit(0);
        $wh[] = ['is_deliver','=',1];
        $wh[] = ['is_finish','=',0];
        $wh[] = ['status','=',1];
        $ids = Items::field('id,op_account_id')->where($wh)->select();
        foreach ($ids as $k=>$v){
            $w['items_id'] = $v['id'];
            $currency = ItemConsume::where($w)->order('time desc')->limit(7)->avg('currency');
            if($currency > 0){
                $arr['acc_id'] = $v['op_account_id'];
                $arr['currency'] = round($currency,2);
                $a[] = $arr;
            }  
        }
        return $a;
    }
    
    
    
    
    
    
    
    
}